package com.woniuxy.house.provider;

import com.woniuxy.house.entity.Post;
import com.woniuxy.house.entity.PostDetail;
import org.apache.ibatis.jdbc.SQL;

public class PostDetailSqlProvider {
    public static String update(PostDetail postDetail) {
        String sql = new SQL() {
            {
                UPDATE("house_post_detail");
                if (postDetail.getArea() != null && !postDetail.getArea().equals("")) {
                    SET("area=#{area}");
                }
                if (postDetail.getContent() != null && !postDetail.getContent().equals("")) {
                    SET("content=#{content}");
                }
                if (postDetail.getCheckInTime() != null && !postDetail.getCheckInTime().equals("")) {
                    SET("check_in_time=#{checkInTime}");
                }
                if (postDetail.getHouseNeed() != null && !postDetail.getHouseNeed().equals("")) {
                    SET("house_need=#{houseNeed}");
                }
                if (postDetail.getHouseStyle() != null && !postDetail.getHouseStyle().equals("")) {
                    SET("house_style=#{houseStyle}");
                }
                if (postDetail.getLease() != null) {
                    SET("lease=#{lease}");
                }
                if (postDetail.getPrice() != null) {
                    SET("price=#{price}");
                }
                WHERE("id=#{id}");

            }

        }.toString();
        return sql;
    }
}
